package KiemTra;

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

public class BVMH extends JFrame{

	JPanel Ve = new JPanel();
	Thread top, buttom, left, right;
	
	public BVMH(){
		
		setTitle("Bài 2");
		setSize(400,450);
		setVisible(true);
		
		
		JButton bd = new JButton("Bất đầu");
		JButton td = new JButton("Tạm dừng");
		JButton tt = new JButton("Tiếp tục");
		JButton kt = new JButton("Kết thúc");
		
		JPanel p = new JPanel();
		p.add(bd);p.add(td);p.add(tt);p.add(kt);
		
		add(Ve, BorderLayout.CENTER);
		add(p, BorderLayout.SOUTH);
		
		bd.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				top.start();
				buttom.start();
				right.start();
				left.start();
			}
		});
		
		td.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub
				top.suspend();
				buttom.suspend();
				right.suspend();
				left.suspend();
			}
		});
		
		tt.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				top.resume();
				buttom.resume();
				right.resume();
				left.resume();
			}
		});
		
		kt.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				// TODO Auto-generated method stub
				top.stop();
				buttom.stop();
				right.stop();
				left.stop();
				System.exit(0);
			}
		});
		
		top = new BVMHTop(Ve);
		buttom = new BVMHButtom(Ve);
		right = new BVMHRight(Ve);
		left = new BVMHLeft(Ve);
		
	}
	
	
	public static void main(String[] args) {
		new BVMH();

	}

}
